home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77721_inc_MasterWeb.js < prev    next >
Encoding:
Text File  |  2003-02-21  |  4.6 KB  |  161 lines

  1. <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  2. <script language=javascript>
  3.  
  4.     //------------------------------------------------------------------------
  5.     // 
  6.     //    inc_MasterWeb.js:   Resuable  JavaScript functions 
  7.     //                        used accross all the pages
  8.     //
  9.     // Copyright (c) Microsoft Corporation.  All rights reserved.
  10.     //
  11.     //    Date             Description
  12.     //  30/10/2000        Creation date
  13.     //------------------------------------------------------------------------
  14.         // Local variables
  15.          var flag="false";             
  16.          
  17.     //------------------------------------------------------------------------
  18.     // Function to clear the error messages (if any on screen) whenever required
  19.     //------------------------------------------------------------------------
  20.     
  21.     function ClearErr()
  22.     { 
  23.         // checking for the browser type 
  24.         if (IsIE()) 
  25.         {
  26.             document.all("divErrMsg").innerHTML = "";
  27.             // removing the event handling
  28.             document.frmTask.onkeypress = null;
  29.         }
  30.     }    
  31.     
  32.     //------------------------------------------------------------------------
  33.     // Function:    addToListBox
  34.     // Description:    moves the passed textbox value to ListBox
  35.     // input:        objList-List Object 
  36.     //        :        ButtonObject- Remove button
  37.     //        :        strText-Text of the option item
  38.     //        :        strValue-value of the option item
  39.     // output:        btnRemove-Button      
  40.     //------------------------------------------------------------------------
  41.     
  42.     function addToListBox(objList,btnRemove,strText,strValue)
  43.     {
  44.         var blnResult=true;
  45.         // checking for the text value null  
  46.         // If the value passed is null make it as text 
  47.         if (strValue=="")
  48.         {
  49.             strValue=strText;
  50.         }     
  51.         if (strText!="" )
  52.         {
  53.             // check for duplicates not required as duplicates accepted
  54.             if (!chkDuplicate(objList,strText)) 
  55.             {
  56.                 // create a new option in the list box
  57.                 objList.options[objList.length] = new Option(strText,strValue);
  58.                     
  59.                 objList.options[objList.length-1].selected = true;                
  60.                 // enable the Remove button
  61.                 if(btnRemove.disabled)
  62.                     btnRemove.disabled = false ;                
  63.             }
  64.             else
  65.             {
  66.                 blnResult= false;
  67.             }    
  68.         }
  69.         else
  70.         {
  71.             blnResult= false;
  72.         }                
  73.         return blnResult;
  74.     }
  75.     
  76.     
  77.     
  78.     //------------------------------------------------------------------------
  79.     // Function:    chkDuplicate        
  80.     // Description: checks for the duplicate text in the list box
  81.     // input:        Object        -Radio Object
  82.     //         :        strchkName    -value of the Name to be checked
  83.     //returns:        blnDuplicate-Returns true/false on success/failure 
  84.     //------------------------------------------------------------------------
  85.     
  86.     function chkDuplicate(objList,strchkName)
  87.     {
  88.         var i;
  89.         var blnDuplicate=false;
  90.         for(var i=0;i < objList.length;i++)
  91.         {
  92.             if (objList.options[i].text == strchkName)
  93.                 blnDuplicate = true;
  94.         }
  95.         return blnDuplicate;
  96.     }
  97.     
  98.     //------------------------------------------------------------------------
  99.     // Function:    remFromListBox
  100.     // Description:    Removes the passed textbox value from ListBox
  101.     // input:        objList-List Object 
  102.     //        :        ButtonObject- Remove button
  103.     //        :        strText-Text of the option item
  104.     //------------------------------------------------------------------------
  105.     
  106.     function remFromListBox(objList,strText)
  107.     {
  108.         var blnResult=true;
  109.         var remPos;
  110.         // checking for the text value null  
  111.         if (strText!="" )
  112.         {
  113.             // Remove the option from the list box
  114.             remPos = objList.selectedIndex;
  115.             if(remPos >= 0)
  116.                 objList.options[remPos]=null;
  117.         }
  118.         else
  119.         {
  120.             blnResult= false;
  121.         }                
  122.         return blnResult;
  123.     }
  124.     
  125.     //------------------------------------------------------------------------
  126.     // Function :   AddRemoveListBoxItems
  127.     // Description: To Add or remove all the options from the given list
  128.     // Input:        objList -Listbox
  129.     // Returns:
  130.     // Support functions used :    ClearErr
  131.     //------------------------------------------------------------------------
  132.     
  133.     function AddRemoveListBoxItems(objListAdd, objListRem)
  134.     {
  135.         // Clear any previous error messages
  136.         ClearErr();
  137.         var i=0,j;
  138.         
  139.         // number of elements in the list object
  140.         var intListLength = objListRem.length;        
  141.         j = objListAdd.length;        
  142.         
  143.         while(intListLength > 0)
  144.         {                
  145.             if(!chkDuplicate(objListAdd,objListRem.options[i].value))
  146.             {             
  147.                 objListAdd.options[j] = new Option(objListRem.options[i].value,objListRem.options[i].value);
  148.             }
  149.             objListRem.options[i].value = null;                
  150.             j++;i++;
  151.             intListLength--;
  152.         }
  153.             
  154.         intListLength = 0;i=0;
  155.         intListLength = objListRem.length;
  156.         while(i<=intListLength){
  157.         objListRem.options[i] = null;
  158.         intListLength--;}
  159.     }
  160.  
  161. </script>